# -*- makefile -*- ############################################################
#                                                                             #
#  This is the MacOSX Makefile for compiling this package. Check also the     #
#  base makefile for more options.                                            #
#                                                                             #
#  ReyBrujo, 2002 (modified from DJGPP version by Peter Hull)                 #
#                                                                             #
#  23-Sep-2002:                                                               #
#     (RB) Added PREPROCESSOR variable.                                       #
# June-2003 Major mods for OSX (by PH)                                        #
###############################################################################



#                                                                             #
#  Set the compiler and linker. Usually, they are both gcc, gpp or gxx. By    #
#  default, we will compile a C project. If you want to compile C++ sources,  #
#  set COMPILER and LINKER to $(GPP), and the COMPILER_FLAGS to CXXFLAGS.     #
#                                                                             #
COMPILER       := $(GCC)
PREPROCESSOR   := $(GPP) -P -undef
LINKER         := $(GCC)
COMPILER_FLAGS := $(CFLAGS) -I/usr/local/include
OBJDIR         := $(OBJ_DIR)/osx
EXE_SUFFIX     :=
EXEC           := $(BIN_DIR)/$(ID_SHORT)
PLATFORM_CODE  :=$(SRC_DIR)/platform/osx.m
NO_PERL        :=1
COMPILER_FLAGS+=-DHAVE_GETPWUID
APPR           :=KQ.app/Contents/Resources
 
###############################################################################
#                                                                             #
#                        END OF CONFIGURATION SECTION                         #
#                                                                             #
###############################################################################

# Unix uses allegro-config rather than -lalleg (or whatever) 
ifdef DEBUG
ALLEGRO = `allegro-config --libs debug`
else
ifdef PROFILE
ALLEGRO  = `allegro-config --libs profile`
else
ALLEGRO  = `allegro-config --static release` -lalleg-main
endif
endif


#                                                                             #
#  Convert all libraries needed so that GCC can understand them.              #
#                                                                             #
LDLIBS += $(addprefix -l, $(LIBRARY)) $(ALLEGRO)
FILES+=osx.m


#                                                                             #
#  Find out the objects we must generate.                                     #
#                                                                             #
OBJECTS := $(addprefix $(OBJDIR)/, $(addsuffix .$(OBJ_SUFFIX), $(FILES) platform))

#                                                                             #
#  By default,  build the project and scripts.                                #
#                                                                             #
bundle: $(EXEC)
	install -d $(APPR)/data $(APPR)/music $(APPR)/scripts $(APPR)/maps 
	install -d KQ.app/Contents/MacOS
	install -C Mac/Info.plist KQ.app/Contents
	install -C bin/kq KQ.app/Contents/MacOS
	install -C data/*.dat data/*.kq data/*.mon $(APPR)/data
	install -C maps/*.map $(APPR)/maps
	install -C music/*.s3m music/*.mod music/*.xm $(APPR)/music
	install -C scripts/*.lob $(APPR)/scripts
	install Mac/KQ-icon.icns $(APPR)/KQ.icns

$(OBJDIR)/%.o:$(SRC_DIR)/%.m
	$(COMPILE.m) $< -o $@

